<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div style="margin :0px auto; width:990px;">

    <input type="file" name="file" id="doc" multiple="multiple" style="width:150px;" onchange="javascript:setImagePreviews();" accept="image/*">

    <div id="dd" style=" width:990px;"></div>
</div>
<script type="text/javascript">

    //下面用于多图片上传预览功能

    function setImagePreviews(avalue) {

        var docObj = document.getElementById("doc");

        var dd = document.getElementById("dd");

        dd.innerHTML = "";

        var fileList = docObj.files;
        console.log(fileList);

//        for (var i = 0; i < fileList.length; i++) {

            dd.innerHTML = "<div style='float:left' > <img id='img' /> </div>";

            var imgObjPreview = document.getElementById("img");

            if (docObj.files && docObj.files[0]) {

                //火狐下，直接设img属性

//                imgObjPreview.style.display = 'block';
//
//                imgObjPreview.style.width = '150px';
//
//                imgObjPreview.style.height = '180px';

//                imgObjPreview.src = docObj.files[0].getAsDataURL();

                //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式

                imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);

            }



        return true;

    }

</script>
</body>
</html>